package cn.dev.mybatis.handler.executor;

import cn.dev.mybatis.bean.SqlObject;
import cn.dev.mybatis.handler.SqlExecutor;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public abstract class AbstractSqlExecutor implements SqlExecutor {
    final SqlObject sqlObject;

    public AbstractSqlExecutor(SqlObject sqlObject) {
        this.sqlObject = sqlObject;
    }

    public void addParam(PreparedStatement ps, Object[] args) throws SQLException {
        if (args == null) {
            return;
        }
        for (int i = 0; i < args.length; i++) {
            ps.setObject(i + 1, args[i]);
        }
    }
}
